 <html>
 <head>
 <title>y_my_own_small_code.f90</title>                                         
                                                                                
                                           
 </head>
 <body>
MODULE MY_OWN_LITTLE_CODE_UTILITIES <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
USE MY_OWN_DA <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
USE MY_ANALYSIS <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
INTEGER, PARAMETER :: NMUL=3 <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
LOGICAL ::  DELTA_IS_3RD_PARAMETER=.FALSE. <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
LOGICAL ::  PSEUDO_RADIATION=.FALSE. <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
REAL(DP) :: CRAD=1.E-4_DP,CFLUC=1.E-5_DP     not used yet                                                                                                                                                                                                                                                                                                                                                                                                                                                           
PRIVATE ADD_R_M,ADD_M_R <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
 <a name="RAY"></a>
<font color="#FF00FF">TYPE RAY </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TYPE(MY_TAYLOR) Z(3)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                      
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; REAL(DP) STOCHASTIC_ENVELOPE(2,2)     &nbsp; not used yet</font>                                                                                                                                                                                                                                                                                                                                                                                                      
<font color="#FF00FF">END TYPE RAY </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
 <a name="MAGNET"></a>
<font color="#FF00FF">TYPE MAGNET </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; REAL(DP) L</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; REAL(DP) BN(0:NMUL)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                       
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; REAL(DP) H</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INTEGER N</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                 
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CHARACTER(8) NAME</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                         
<font color="#FF00FF">END TYPE MAGNET </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
 <a name="+"></a>
<font color="#0000FF">    INTERFACE OPERATOR (+) </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                       
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#ADD_R_M">     MODULE PROCEDURE ADD_R_M</a></font><font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594; &nbsp;  ray+map </font><br>                                                                                                                                                                                                                                                                                 
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#ADD_M_R">     MODULE PROCEDURE ADD_M_R</a></font><font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594; &nbsp;  map+ray </font><br>                                                                                                                                                                                                                                                                                 
<font color="#0000FF">  END INTERFACE </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
CONTAINS <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
 <a name="ADD_R_M"></a>
<font color="#37A50B">  FUNCTION ADD_R_M( S1, S2 ) </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                     
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    IMPLICIT NONE</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    TYPE (MY_TAYLOR) ADD_R_M(3)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                            
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    REAL(DP), INTENT (IN) :: S1(3)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                         
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    TYPE (MY_MAP), INTENT (IN) :: S2</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                       
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      ADD_R_M(1)=S2%V(1)+S1(1)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                             
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      ADD_R_M(2)=S2%V(2)+S1(2)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                             
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     IF(DELTA_IS_3RD_PARAMETER) THEN</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                       
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      ADD_R_M(3)=S1(3)+(1.0_DP.MONOMIAL.3)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                 
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     ELSE</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                  
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      ADD_R_M(3)=S1(3)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                     
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     ENDIF</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                 
<font color="#37A50B">  END FUNCTION ADD_R_M </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
 <a name="ADD_M_R"></a>
<font color="#37A50B">  FUNCTION ADD_M_R( S2, S1 ) </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                     
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    IMPLICIT NONE</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    TYPE (MY_TAYLOR) ADD_M_R(3)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                            
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    REAL(DP), INTENT (IN) :: S1(3)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                         
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    TYPE (MY_MAP), INTENT (IN) :: S2</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                       
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     ADD_M_R(1)=S2%V(1)+S1(1)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                              
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     ADD_M_R(2)=S2%V(2)+S1(2)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                              
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     IF(DELTA_IS_3RD_PARAMETER) THEN</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                       
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      ADD_M_R(3)=S1(3)+(1.0_DP.MONOMIAL.3)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                 
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     ELSE</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                  
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      ADD_M_R(3)=S1(3)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                     
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     ENDIF</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                 
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font color="#37A50B">  END FUNCTION ADD_M_R </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
 <a name="CANONIZE_RAY"></a>
<font color="#FF0000">  SUBROUTINE CANONIZE_RAY( Z,PHASE_ADVANCE, A_CS,DISP,A_L,A_NL ) </font><font color="#009933"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8594; &nbsp; Puts the ray into a special form </font><br>                                                                                                                                                                                                                                                                                                 
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    IMPLICIT NONE</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    TYPE (MY_TAYLOR) , INTENT (INOUT) ::   Z(2)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                            
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    TYPE(MY_TAYLOR), INTENT (INOUT) ::  PHASE_ADVANCE</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                      
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    TYPE(MY_MAP), INTENT (INOUT) ::  A_CS,DISP,A_L,A_NL</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                    
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    TYPE (MY_MAP) A,R</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                      
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    A=Z</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                    
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     CALL CANONIZE( A,A_CS,DISP,A_L,A_NL,R,PHASE_ADVANCE )</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                 
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    Z=A_CS</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                 
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font color="#FF0000">  END SUBROUTINE CANONIZE_RAY </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                    
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
 <a name="TRACK_MAGNET"></a>
<font color="#FF0000">  SUBROUTINE TRACK_MAGNET( R,MAG ) </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                               
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    IMPLICIT NONE</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    TYPE (MY_TAYLOR) Z(3),RAD</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                              
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    TYPE (RAY) , INTENT (INOUT) ::   R</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                     
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    TYPE (MAGNET) , INTENT (IN) ::   MAG</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                   
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    INTEGER N,I,J</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    REAL(DP) DL,FAC</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                        
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    Z=R%Z</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                  
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    IF(MAG%L/=0) THEN</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                      
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     DL=MAG%L/MAG%N</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                        
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    DO I=1,MAG%N</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     Z(1)=Z(1)+DL/2.D0*Z(2)/(1.D0+Z(3))</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                    
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     FAC=1.0_DP</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                            
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     DO J=0,NMUL</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      Z(2)=Z(2)-MAG%BN(J)*DL*Z(1)**(J)/FAC</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                 
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       FAC=FAC*(J+1)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                       
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     ENDDO</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                 
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      Z(2)=Z(2)-MAG%BN(0)*MAG%H*DL*Z(1)+(1.D0+Z(3))*MAG%H*DL</font> <br>                                                                                                                                                                                                                                                                                                                                                                                               
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   IF(PSEUDO_RADIATION)  THEN</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                              
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     RAD=0.0_DP</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                            
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     FAC=1.0_DP</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                            
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     DO J=0,NMUL</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      RAD=RAD+(MAG%BN(J)*Z(1)**(J)/FAC)**2</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                 
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       FAC=FAC*(J+1)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                       
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     ENDDO</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                 
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     Z(1)=Z(1)-DL*CRAD*RAD*Z(1)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                            
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   ENDIF</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                   
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     Z(1)=Z(1)+DL/2.D0*Z(2)/(1.D0+Z(3))</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                    
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    ENDDO</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                  
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   ELSE</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                    
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     FAC=1.0_DP</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                            
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     DO J=0,NMUL</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      Z(2)=Z(2)-MAG%BN(J)*Z(1)**(J)/FAC</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                    
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      FAC=FAC*(J+1)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                        
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    ENDDO</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                  
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   ENDIF</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                   
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   R%Z=Z</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                   
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font color="#FF0000">  END SUBROUTINE TRACK_MAGNET </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                    
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
 <a name="TRACK_LATTICE"></a>
<font color="#FF0000">    SUBROUTINE TRACK_LATTICE( R,L,LOC1, LOC2) </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                    
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    IMPLICIT NONE</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    TYPE (MAGNET) , INTENT (IN) ::   L(:)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                  
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    TYPE (RAY) , INTENT (INOUT) ::  R</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                      
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    INTEGER N,LOC1, LOC2,I</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                 
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    N=SIZE(L)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                              
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    IF(LOC1> N) STOP 1</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                     
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    IF(LOC2> N) STOP 2</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                     
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    IF(LOC2>LOC1) THEN</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                     
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     DO I=LOC1,LOC2-1</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                      
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      CALL TRACK_MAGNET( R,L(I) )</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                          
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     ENDDO</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                 
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    ELSEIF(LOC1>=LOC2) THEN</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     DO I=LOC2,N</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      CALL TRACK_MAGNET( R,L(I) )</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                          
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     ENDDO</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                 
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     DO I=1,LOC1-1</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                         
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      CALL TRACK_MAGNET( R,L(I) )</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                          
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     ENDDO</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                 
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    ENDIF</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                  
<font color="#FF0000">    END SUBROUTINE TRACK_LATTICE </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                 
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
 <a name="FIND_CLOSED_ORBIT"></a>
<font color="#FF0000">    SUBROUTINE FIND_CLOSED_ORBIT( FIX,L,LOC) </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                     
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    IMPLICIT NONE</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    REAL(DP) FIX(3),DFIX(2)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    TYPE (MAGNET) , INTENT (IN) ::   L(:)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                  
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    TYPE(MY_MAP) M,ID</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                      
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    TYPE(RAY) R</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                            
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    INTEGER LOC,I,MY_OLD_TAYLOR</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                            
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    REAL(DP) DNORM1,DNORM2</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                 
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    ID=1</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                   
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    MY_OLD_TAYLOR=MY_ORDER</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                 
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    MY_ORDER=1</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                             
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    DNORM1=-1</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                              
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    DO I=1,100</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                             
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       M=1</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                 
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       R%Z=FIX+M</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       CALL TRACK_LATTICE(R,L,LOC,LOC)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                     
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       M=R%Z</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                               
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       M%V(1)=M%V(1)-ID%V(1)-FIX(1)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                        
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       M%V(2)=M%V(2)-ID%V(2)-FIX(2)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                        
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       M=M.OO.(-1)</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                         
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       DFIX=M</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                              
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       FIX(1:2)=FIX(1:2)+DFIX</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                              
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;        DNORM2=ABS(DFIX(1))+ABS(DFIX(2))</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                   
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       IF(I>10) THEN</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                       
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;        IF(DNORM2>=DNORM1) EXIT</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                            
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       ENDIF</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                               
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;        DNORM1=DNORM2</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                      
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    ENDDO</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                  
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     IF(I>99) WRITE(6,*) " FIND_CLOSED_ORBIT DID NOT CONVERGED "</font> <br>                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    MY_ORDER=MY_OLD_TAYLOR</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                 
<font size= -1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                           
<font color="#FF0000">    END SUBROUTINE FIND_CLOSED_ORBIT </font> <br>                                                                                                                                                                                                                                                                                                                                                                                                                                             
END MODULE MY_OWN_LITTLE_CODE_UTILITIES <br>                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
<hr color="#CC0000" size="10" align="left" noshade>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
 </body>
 </html>
